home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mntdoc01.zoo / mintdoc / cat2 / pmsg.nr < prev    next >
Encoding:
Text File  |  1993-03-03  |  3.3 KB  |  133 lines

  1.  
  2.  
  3.  
  4. Pmsg(2)                    Oct. 1, 1991                   Pmsg(2)
  5.  
  6.  
  7. N✓NA✓AM✓ME✓E
  8.        Pmsg - send and receive brief messages
  9.  
  10. S✓SY✓YN✓NO✓OP✓PS✓SI✓IS✓S
  11.        struct msg { LONG msg1, msg2; WORD pid; };
  12.  
  13.        LONG Pmsg( WORD mode, LONG mboxid, struct msg *msgptr );
  14.  
  15. D✓DE✓ES✓SC✓CR✓RI✓IP✓PT✓TI✓IO✓ON✓N
  16.        _✓P_✓m_✓s_✓g  sends  or  receives a message to a specified message
  17.        box. What sort of operation is performed  depends  on  the
  18.        bits in _✓m_✓o_✓d_✓e as follows:
  19.           Mode        Operation
  20.           0x0000      read
  21.           0x0001      write
  22.           0x0002      write, then read from mboxid 0xFFFFxxxx where
  23.                    xxxx is the process id of the current process
  24.  
  25.           0x8000      OR with this bit to make the operation
  26.                    non-blocking.
  27.  
  28.        The  messages  are five words long: two longs and a short,
  29.        in that order.  The values  of the  first  two  longs  are
  30.        totally up to the processes in question.  The value of the
  31.        short is the PID of the sender.  On  return  from  writes,
  32.        the  short  is  the PID of the process that read your mes-
  33.        sage.  On return from reads, it's the PID of the writer.
  34.  
  35.        If the 0x8000 bit is set in the mode, and there is  not  a
  36.        reader/writer  for  the  mboxid already, this call returns
  37.        -1. Otherwise, a read operation waits until a  message  is
  38.        written  and  a  write  operation  waits  for  a reader to
  39.        receive the message.
  40.  
  41.        In mode 2, the writer is declaring that it wants  to  wait
  42.        for  a  reply  to  the  message.  What happens is that the
  43.        reader gets put on the ready  queue,  but  the  writer  is
  44.        atomically  turned into a reader on a mailbox whose mboxid
  45.        is (0xFFFF0000 | pid). The idea is that this process  will
  46.        sleep  until  awoken  at  a later time by the process that
  47.        read  the  message.   The  process  reading  the  original
  48.        request is guaranteed not to block when writing the reply.
  49.  
  50.  
  51. R✓RE✓ET✓TU✓UR✓RN✓NS✓S
  52.        0 if successful
  53.  
  54.        -1 if bit 0x8000 is set and the P✓Pm✓ms✓sg✓g call  would  have  to
  55.        block
  56.  
  57.        EINVFN if _✓m_✓o_✓d_✓e is invalid
  58.  
  59. U✓US✓SA✓AG✓GE✓E
  60.        Used  for short messages and as a way to do rendezvous and
  61.  
  62.  
  63.  
  64. Version 0.9          MiNT Programmer's Manual                   1
  65.  
  66.  
  67.  
  68.  
  69.  
  70. Pmsg(2)                    Oct. 1, 1991                   Pmsg(2)
  71.  
  72.  
  73.        interprocess communication with little overhead. For  more
  74.        complicated  messages  or  more  general IPC, use FIFOs or
  75.        pseudo-terminals.
  76.  
  77. B✓BU✓UG✓GS✓S
  78.        There is no provision for a timeout.
  79.  
  80.        No checking is done for deadlocks. A deadlock could  arise
  81.        in  the  following  way:  Say PID 33 writes in mode 2 to a
  82.        message box and it blocks. Then somebody writes to PD33  (
  83.        _✓i_✓._✓e_✓.   message  box (0xFFFF0000 | 33) ) and blocks because
  84.        you're not waiting for it.  Then your write is  satisfied,
  85.        so you become a reader on PD33.  We should check to see if
  86.        there are any writers on PD33 and satisfy that rendezvous!
  87.        But  this  could  go  on  forever, and it's easier to stop
  88.        here.  So you lose: this situation  is  timing  sensitive.
  89.        It shouldn't come up anyway.
  90.  
  91. A✓AU✓UT✓TH✓HO✓OR✓R
  92.        Allan K. Pratt
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. Version 0.9          MiNT Programmer's Manual                   2
  131.  
  132.  
  133.